package com.yy.weixinpay.controller;

import com.yy.weixinpay.config.WxPayConfig;
import com.yy.weixinpay.entity.Product;
import com.yy.weixinpay.service.ProductService;
import com.yy.weixinpay.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/product")
@Api(tags = "商品管理")
@CrossOrigin
public class ProductController {
    @Autowired
    private WxPayConfig wxPayConfig;
    @Autowired
    private ProductService productService;
    @GetMapping("/test")
    @ApiOperation("测试")
    public R product(){
        System.out.println("hello");
        System.out.println(wxPayConfig.toString());
        return R.ok();
    }


    @ApiOperation("查询所有产品")
    @GetMapping("/list")
    public R list(){
        List<Product> list = productService.list();
        System.out.println(list);
        return R.ok().data("productList",list);
    }
}
